import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 22652
 * Date: 2024-09-26
 * Time: 21:35
 */
public class test_1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n=in.nextInt();
            while (n>0){
                int y=in.nextInt();
                int o=in.nextInt();
                int u=in.nextInt();
                int num=sum_you(y,o,u)
                n--;
        }
    }
}

    private static int sum_you(int y, int o, int u) {
        int ret=0;
        while (y>0&&o>0&&u>0){
            y--;
            o--;
            u--;
            ret+=2;
        }
        o--;
        if (o>0){
            ret+=o;
        }
        r
    }
}
